package com.itcast.manager3.D_dao;

import com.itcast.manager3.tomian.ShareholderTomain;

import java.util.ArrayList;

public class ShareholderDao {
    ArrayList<ShareholderTomain> list = new ArrayList<>();

    public ArrayList<ShareholderTomain> getShareholdList() {
        return list;
    }

    public void addShareholder(ShareholderTomain sdd) {
        list.add(sdd);
    }

    public void deleteShareholder(String id) {
        for (int i = 0; i < list.size(); i++) {
            ShareholderTomain tomain = list.get(i);
            if (tomain.getId().equals(id)) {
                list.remove(i);
            }
        }
    }

    public void updateShareholder(ShareholderTomain sto) {
        for (int i = 0; i < list.size(); i++) {
            ShareholderTomain tomain = list.get(i);
            if (tomain.getId().equals(sto.getId())){
                tomain.setName(sto.getName());
                tomain.setName(sto.getName());
                tomain.setName(sto.getName());
            }
        }
    }
}
